/**
 * Stage
 */
function Stage(canvas){
    this.name = Namer.createUniqueName('Stage');
    this.canvas = canvas;
    this.context = this.canvas.getContext('2d');
    this.mouseX = 0;//The x coordinate of mouse position on stage.
    this.mouseY = 0;//The y coordinate of mouse position on stage.
    this.width = this.canvas.width;
    this.height = this.canvas.height;
    
    //@protected
    this._frameRate = 0;
    this._paused = false;
    this._pauseInNextFrame = false;
    
    //delegate mouse events on the canvas
    //TODO
}
Stage.prototype = new Container();
Stage.prototype.constructor = Stage;

//Clears the canvas by specific rectangle, if not set, clear the whole canvas
Stage.prototype.clear = function(x, y, width, height){
    if(arguments.length >= 4){
        this.context.clearRect(x, y, width, height);
    }else{
        this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
    }
}

//Gets the frame rate of the stage.
Stage.prototype.getFrameRate = function(){
    return this._frameRate;
}

Stage.prototype.isPaused = function(){
    return this._paused;
}

Stage.prototype.setPaused = function(pause, pauseInNextFrame){
    if(this._paused == pause) return;
    this._paused = pause;
    //sometimes we need to pause after rendering current frame
    this._pauseInNextFrame = pauseInNextFrame || false;
}

//Sets the mouse cursor type of the stage.
Stage.prototype.setCursor = function(cursor){
    //TODO
}

//Sets the frame rate of the stage.
Stage.prototype.setFrameRate = function(frameRate){
    this._frameRate = frameRate;
}

Stage.prototype.getStageWidth = function(){
    return this.width;
}

Stage.prototype.getStageHeight = function(){
    return this.height;
}